package com.bw.controller;

import com.bw.domain.TUser;
import com.bw.service.TUserService;
import com.bw.utils.common.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author bobo棒
 * @date 2023年12月20日 9:37
 */

@RequestMapping("user")
@RestController
public class UserController {
    @Autowired
    TUserService tUserService;

    @RequestMapping("list")
    public Result list(@RequestBody TUser tUser,@RequestParam(defaultValue = "1") Integer pageNum){

        PageHelper.startPage(pageNum, 10);
     List<TUser> list= tUserService.listByCondtion(tUser);
     return Result.success(new PageInfo<>(list));
    }


    @RequestMapping("del")
    public Result del(Integer id){
        boolean b = tUserService.removeById(id);
        return b?Result.success():Result.fail();
    }
}
